/*
 * Copyright 2011-2020 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0.
 * See `LICENSE` in the project root for license information.
 */

package me.ijleex.mgmt.codegen.entity;

import java.util.List;

import org.apache.ibatis.type.Alias;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.base.MoreObjects;

import me.ijleex.mgmt.framework.entity.EntitySupport;

/**
 * 数据库表信息（information_schema.tables）
 *
 * <p>https://dev.mysql.com/doc/refman/8.0/en/tables-table.html</p>
 *
 * @author liym
 * @since 2019-02-22 11:27 新建
 */
@Alias("TableInfo")
public class TableInfo extends EntitySupport {

    /**
     * 数据库名
     */
    private String tableSchema;
    /**
     * 数据表名
     */
    private String tableName;
    /**
     * 存储引擎
     */
    private String engine;
    /**
     * 表描述
     */
    private String tableComment;

    // -------------------- 关联的列信息 --------------------

    /**
     * 表的列信息（不包含主键）
     */
    @JsonIgnore
    private List<ColumnInfo> columns;
    /**
     * 表的主键列信息，用于设置更新数据的条件
     */
    @JsonIgnore
    private ColumnInfo primaryKey;

    // -------------------- 代码生成参数 --------------------

    /**
     * Java 类名（第一个字母大写，如 CodeGenMapper）
     */
    @JsonIgnore
    private String className;
    /**
     * Java 类变量名（第一个字母小写，如 codeGenMapper）
     */
    @JsonIgnore
    private String classVarName;

    public String getTableSchema() {
        return this.tableSchema;
    }

    public void setTableSchema(String tableSchema) {
        this.tableSchema = tableSchema;
    }

    public String getTableName() {
        return this.tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getEngine() {
        return this.engine;
    }

    public void setEngine(String engine) {
        this.engine = engine;
    }

    public String getTableComment() {
        return this.tableComment;
    }

    public void setTableComment(String tableComment) {
        this.tableComment = tableComment;
    }

    public List<ColumnInfo> getColumns() {
        return this.columns;
    }

    public void setColumns(List<ColumnInfo> columns) {
        this.columns = columns;
    }

    public ColumnInfo getPrimaryKey() {
        return this.primaryKey;
    }

    public void setPrimaryKey(ColumnInfo primaryKey) {
        this.primaryKey = primaryKey;
    }

    public String getClassName() {
        return this.className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getClassVarName() {
        return this.classVarName;
    }

    public void setClassVarName(String classVarName) {
        this.classVarName = classVarName;
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("tableName", this.tableName)
                .add("tableComment", this.tableComment)
                .toString();
    }

}
